package com.ruoyi.project.backInOrder.controller;

import java.util.List;

import com.ruoyi.project.backInOrder.service.IBackInOrderServiceZx;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.backInOrder.domain.BackInOrderZx;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 入库回传表Controller
 * 
 * @author ruoyi
 * @date 2024-02-05
 */
@Controller
@RequestMapping("/backInOrder/backorder")
public class BackInOrderZxController extends BaseController
{
    private String prefix = "backInOrder";

    @Autowired
    private IBackInOrderServiceZx backInOrderService;

    @GetMapping()
    public String backorder()
    {
        return prefix + "/backorder";
    }

    /**
     * 查询入库回传表列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BackInOrderZx backInOrder)
    {
        startPage();
        List<BackInOrderZx> list = backInOrderService.selectBackInOrderList(backInOrder);
        return getDataTable(list);
    }

    /**
     * 导出入库回传表列表
     */
    @Log(title = "入库回传表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BackInOrderZx backInOrder)
    {
        List<BackInOrderZx> list = backInOrderService.selectBackInOrderList(backInOrder);
        ExcelUtil<BackInOrderZx> util = new ExcelUtil<BackInOrderZx>(BackInOrderZx.class);
        return util.exportExcel(list, "入库回传表数据");
    }

    /**
     * 新增入库回传表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存入库回传表
     */
    @Log(title = "入库回传表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BackInOrderZx backInOrder)
    {
        return toAjax(backInOrderService.insertBackInOrder(backInOrder));
    }

    /**
     * 修改入库回传表
     */
    @GetMapping("/edit/{billId}")
    public String edit(@PathVariable("billId") String billId, ModelMap mmap)
    {
        BackInOrderZx backInOrder = backInOrderService.selectBackInOrderByBillId(billId);
        mmap.put("backInOrder", backInOrder);
        return prefix + "/edit";
    }

    /**
     * 修改保存入库回传表
     */
    @Log(title = "入库回传表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BackInOrderZx backInOrder)
    {
        return toAjax(backInOrderService.updateBackInOrder(backInOrder));
    }

    /**
     * 删除入库回传表
     */
    @Log(title = "入库回传表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(backInOrderService.deleteBackInOrderByBillIds(ids));
    }
}
